package com.xbongbong.saas.enums;


import java.util.ArrayList;
import java.util.List;

/**
 * 打印模板 枚举
 *
 * @author zheng.li
 */
public enum PrintTemplateTypeEnum {
    /**
     * 合同订单
     */
    CONTRACT(RedundantTemplateTypeEnum.CONTRACT, XbbRefTypeEnum.CRM.getAlias()),
    /**
     * 退货退款
     */
    REFUND(RedundantTemplateTypeEnum.REFUND, XbbRefTypeEnum.CRM.getAlias()),
    /**
     * 销售机会
     */
    SALES_OPPORTUNITY(RedundantTemplateTypeEnum.SALES_OPPORTUNITY, XbbRefTypeEnum.CRM.getAlias()),
    /**
     * 报价单
     */
    QUOTATION(RedundantTemplateTypeEnum.QUOTATION, XbbRefTypeEnum.CRM.getAlias()),
    /**
     * 工作报告
     */
    WORKREPORT(RedundantTemplateTypeEnum.WORKREPORT, XbbRefTypeEnum.CRM.getAlias()),
    /**
     * 日报
     */
    WORKREPORT_DAILY(RedundantTemplateTypeEnum.WORKREPORT_DAILY, XbbRefTypeEnum.CRM.getAlias()),
    /**
     * 周报
     */
    WORKREPORT_WEEKLY(RedundantTemplateTypeEnum.WORKREPORT_WEEKLY, XbbRefTypeEnum.CRM.getAlias()),
    /**
     * 月报
     */
    WORKREPORT_MONTHLY(RedundantTemplateTypeEnum.WORKREPORT_MONTHLY, XbbRefTypeEnum.CRM.getAlias()),
    /**
     * 采购合同
     */
    PURCHASE(RedundantTemplateTypeEnum.PURCHASE, XbbRefTypeEnum.JXC.getAlias()),
    /**
     * 采购退货单
     */
    RETURNED_PURCHASE(RedundantTemplateTypeEnum.RETURNED_PURCHASE, XbbRefTypeEnum.JXC.getAlias()),
    /**
     * 入库单
     */
    INSTOCK(RedundantTemplateTypeEnum.INSTOCK, XbbRefTypeEnum.JXC.getAlias()),
    /**
     * 采购入库单
     */
    PURCHASE_INSTOCK(RedundantTemplateTypeEnum.PURCHASE_INSTOCK, XbbRefTypeEnum.JXC.getAlias()),
    /**
     * 销售退货入库
     */
    REFUND_INSTOCK(RedundantTemplateTypeEnum.REFUND_INSTOCK, XbbRefTypeEnum.JXC.getAlias()),
    /**
     * 生产入库单
     */
    PRODUCTION_INSTOCK(RedundantTemplateTypeEnum.PRODUCTION_INSTOCK, XbbRefTypeEnum.JXC.getAlias()),
    /**
     * 生产退料单
     */
    RETURNED_MATERIEL_INSTOCK(RedundantTemplateTypeEnum.RETURNED_MATERIEL_INSTOCK, XbbRefTypeEnum.JXC.getAlias()),
    /**
     * 其他入库单
     */
    OTHER_INSTOCK(RedundantTemplateTypeEnum.OTHER_INSTOCK, XbbRefTypeEnum.JXC.getAlias()),
    /**
     * 出库单
     */
    OUTSTOCK(RedundantTemplateTypeEnum.OUTSTOCK, XbbRefTypeEnum.JXC.getAlias()),
    /**
     * 工单出库单
     */
    WORK_ORDER_OUTSTOCK(RedundantTemplateTypeEnum.WORK_ORDER_OUTSTOCK, XbbRefTypeEnum.JXC.getAlias()),
    /**
     * 销售出库单
     */
    CONTRACT_OUTSTOCK(RedundantTemplateTypeEnum.CONTRACT_OUTSTOCK, XbbRefTypeEnum.JXC.getAlias()),
    /**
     * 采购退货出库单
     */
    RETURNED_PURCHASE_OUTSTOCK(RedundantTemplateTypeEnum.RETURNED_PURCHASE_OUTSTOCK, XbbRefTypeEnum.JXC.getAlias()),
    /**
     * 生产领料单
     */
    PRODUCTION_MATERIEL_OUTSTOCK(RedundantTemplateTypeEnum.PRODUCTION_MATERIEL_OUTSTOCK, XbbRefTypeEnum.JXC.getAlias()),
    /**
     * 其他出库单
     */
    OTHER_OUTSTOCK(RedundantTemplateTypeEnum.OTHER_OUTSTOCK, XbbRefTypeEnum.JXC.getAlias()),
    /**
     * 盘点单
     */
    INVENTORY(RedundantTemplateTypeEnum.INVENTORY, XbbRefTypeEnum.JXC.getAlias()),
    /**
     * 调拨单
     */
    TRANSFER(RedundantTemplateTypeEnum.TRANSFER, XbbRefTypeEnum.JXC.getAlias()),
    /**
     * 装配出入库单
     */
    ASSEMBLE(RedundantTemplateTypeEnum.ASSEMBLE, XbbRefTypeEnum.JXC.getAlias()),
    /**
     * BOM清单
     */
    BOMBILL(RedundantTemplateTypeEnum.BOMBILL, XbbRefTypeEnum.JXC.getAlias()),
    /**
     * BOM生产单
     */
    PRODUCTIONORDER(RedundantTemplateTypeEnum.PRODUCTIONORDER,XbbRefTypeEnum.JXC.getAlias()),
    /**
     * 回款单
     */
    PAYMENT_SHEET(RedundantTemplateTypeEnum.PAYMENT_SHEET,XbbRefTypeEnum.FUND_MANAGEMENT.getAlias()),
    /**
     * 应收款
     */
    PAYMENT(RedundantTemplateTypeEnum.PAYMENT,XbbRefTypeEnum.FUND_MANAGEMENT.getAlias()),
    /**
     * 发票
     */
    INVOICE(RedundantTemplateTypeEnum.INVOICE,XbbRefTypeEnum.FUND_MANAGEMENT.getAlias()),
    /**
     * 付款单
     */
    PAY_SHEET(RedundantTemplateTypeEnum.PAY_SHEET,XbbRefTypeEnum.PAY_MANAGEMENT.getAlias()),
    /**
     * 付款计划
     */
    PAY_PLAN(RedundantTemplateTypeEnum.PAY_PLAN,XbbRefTypeEnum.PAY_MANAGEMENT.getAlias()),
    /**
     * 进项发票
     */
    INVOICE_PURCHASE(RedundantTemplateTypeEnum.PURCHASE_INVOICE,XbbRefTypeEnum.PAY_MANAGEMENT.getAlias()),
    /**
     * 工单
     */
    WORKORDER(RedundantTemplateTypeEnum.WORKORDER,XbbRefTypeEnum.WORK_ORDER.getAlias()),

    /**
     * 客户对账单
     */
    CUSTOMER_STATEMENT(RedundantTemplateTypeEnum.CUSTOMER_STATEMENT, XbbRefTypeEnum.FUND_MANAGEMENT.getAlias()),

    CUSTOMER_STATEMENT_STATISTIC(RedundantTemplateTypeEnum.CUSTOMER_STATEMENT_STATISTIC, XbbRefTypeEnum.FUND_MANAGEMENT.getAlias()),

    /**
     * 其他收入单
     */
    OTHER_INCOME(RedundantTemplateTypeEnum.OTHER_INCOME,XbbRefTypeEnum.FUND_MANAGEMENT.getAlias()),
    /**
     * 其他收入单
     */
    OTHER_EXPENSE(RedundantTemplateTypeEnum.OTHER_EXPENSE,XbbRefTypeEnum.FUND_MANAGEMENT.getAlias()),
    /**
     * 资金调拨单
     */
    FUND_TRANSFER(RedundantTemplateTypeEnum.FUND_TRANSFER,XbbRefTypeEnum.FUND_MANAGEMENT.getAlias()),

    /**
     * 成本调整单
     */
    COST_ADJUST(RedundantTemplateTypeEnum.COST_ADJUST,XbbRefTypeEnum.COST_ADJUST.getAlias()),

    /**
     * 回执单
     */
    RECEIPT_ORDER(RedundantTemplateTypeEnum.RECEIPT_ORDER,XbbRefTypeEnum.WORK_ORDER_V2_CENTER.getAlias()),

    WORK_ORDER_V2(RedundantTemplateTypeEnum.WORK_ORDER_V2,XbbRefTypeEnum.WORK_ORDER_V2_CENTER.getAlias()),

    UNKNOWN(RedundantTemplateTypeEnum.UNKNOWN,""),

	;

    /**
     * 枚举值 --
     */
    private final int code;
    /**
     * 枚举描述 --英文名称
     */
    private final String alias;
    /**
     * 所属应用
     */
    private String app;

    /**
     * 构造一个<code>PrintTemplateTypeEnum</code>枚举对象
     *
     * @param code  枚举Code
     * @param alias 枚举别名
     */
    PrintTemplateTypeEnum(int code, String alias, String app) {
        this.code = code;
        this.alias = alias;
        this.app = app;
    }

    PrintTemplateTypeEnum(RedundantTemplateTypeEnum redundantTemplateTypeEnum, String app) {
        this.code = redundantTemplateTypeEnum.getCode();
        this.alias = redundantTemplateTypeEnum.getAlias();
        this.app = app;
    }

    public int getCode() {
        return code;
    }

    public String getAlias() {
        return alias;
    }

    public String getApp() {
        return app;
    }

    /**
     * 通过枚举 alias 获得枚举
     *
     * @param alias 枚举别名
     * @return PrintTemplateTypeEnum
     */
    public static PrintTemplateTypeEnum getByAlias(String alias) {
        for (PrintTemplateTypeEnum cacheCode : values()) {
            if (cacheCode.getAlias().equals(alias)) {
                return cacheCode;
            }
        }
        return UNKNOWN;
    }

    /**
     * 通过枚举 code 获得枚举
     *
     * @param code 枚举Code
     * @return PrintTemplateTypeEnum
     */
    public static PrintTemplateTypeEnum getByCode(Integer code) {
        if (code == null) {
            return UNKNOWN;
        }
        for (PrintTemplateTypeEnum cacheCode : values()) {
            if (code.equals(cacheCode.getCode())) {
                return cacheCode;
            }
        }
        return UNKNOWN;
    }

    /**
     * 获取全部枚举
     *
     * @return List<PrintTemplateTypeEnum>
     */
    public static List<PrintTemplateTypeEnum> getAllEnums() {
        List<PrintTemplateTypeEnum> list = new ArrayList<>();
        for (PrintTemplateTypeEnum cache : values()) {
            if (cache == UNKNOWN) {
                continue;
            }
            list.add(cache);
        }
        return list;
    }

    /**
     * 获取全部枚举值
     *
     * @return List<String>
     */
    public static List<String> getAllEnumAlis() {
        List<String> list = new ArrayList<>();
        for (PrintTemplateTypeEnum cache : values()) {
            if (cache == UNKNOWN) {
                continue;
            }
            list.add(cache.getAlias());
        }
        return list;
    }

    public static List<Integer> getAllEnumCodes() {
        List<Integer> list = new ArrayList<>();
        for (PrintTemplateTypeEnum cache : values()) {
            if (cache == UNKNOWN) {
                continue;
            }
            list.add(cache.getCode());
        }
        return list;
    }

}
